import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [vue()],
  server: {
    cors: true, // 默认启用并允许任何源
    //反向代理配置，注意rewrite写法，开始没看文档在这里踩了坑
    proxy: {
        '/api': {
            target: 'http://localhost:3001',   //代理接口
            changeOrigin: true,
            rewrite: (path) => path.replace(/^\/api/, '')
      }
    }
}
})
